"""
 -*- coding: utf-8-*-
 @File: util_log.py
 @Author: chen
 @time: 2023/10/22/ 16:40
"""
import datetime
import logging
import os

now = datetime.datetime.now()
date_time = now.strftime("%Y-%m-%d")
logger = logging.getLogger(os.path.basename(__file__))
logger.setLevel(logging.DEBUG)
console_handler = logging.StreamHandler()
cur_path = os.path.dirname(os.path.abspath(__file__))
log_file = os.path.join(cur_path, f"../logs/{date_time}.log")
file_handler = logging.FileHandler(filename=log_file, encoding="utf-8")
console_handler.setLevel(logging.DEBUG)
file_handler.setLevel(logging.DEBUG)
formatter = logging.Formatter("%(asctime)s|%(filename)s:%(lineno)s|%(levelname)s|msg：%(msg)s")
console_handler.setFormatter(formatter)
file_handler.setFormatter(formatter)
logger.addHandler(console_handler)
logger.addHandler(file_handler)
logger.info("*" * 69)
